﻿#ifndef SEARCHITEM_H
#define SEARCHITEM_H

#include <QWidget>
#include <QImageReader>
#include <QPainter>
#include <QPainterPath>
#include <QMouseEvent>
#include <QFile>

namespace Ui {
class SearchItem;
}

class SearchItem : public QWidget
{
    Q_OBJECT

public:
    explicit SearchItem(const QString &email,const QString &username,QWidget *parent = nullptr);
    ~SearchItem();
    void updateStatus();
    QString getEmail();
signals:
    void addFriend(const QString &Temail,const QString &username);
    void onClicked(const QString &email);
public slots:
    void setTemporaryImage(QObject* sender,const QString &email,const QByteArray &data);
protected:
    void mousePressEvent(QMouseEvent *event);
private:
    Ui::SearchItem *ui;
    QString email;
    bool isEmailMatched(const QString &email);
    void setHeadImageLabelPixmap(const QPixmap &pixmap);
    QImage squareImageToCircle(const QImage &squareImage);
    void updateHeadImg();
};

#endif // SEARCHITEM_H
